<?php

declare(strict_types=1);

use Monolog\Level;

/**
 * This file is part of Hyperf.
 *
 * @link     https://www.hyperf.io
 * @document https://hyperf.wiki
 * @contact  group@hyperf.io
 * @license  https://github.com/hyperf/hyperf/blob/master/LICENSE
 */
$dateFormat = 'Y-m-d H:i:s';
$format = "[%datetime%] %channel%·%level_name%  %message%  %context%\n";

$logger_path = BASE_PATH . '/runtime/logger';

return [
    'default' => [//默认日志记录
        'handler' => [
            'class' => Monolog\Handler\RotatingFileHandler::class,
            'constructor' => [
                'filename' => $logger_path . '/app/app.log',
                'level' => Level::Debug
            ]
        ],
        'formatter' => [
            'class' => Monolog\Formatter\LineFormatter::class,
            'constructor' => [
                'format' => $format,
                'dateFormat' => $dateFormat,
                'allowInlineLineBreaks' => true
            ]
        ]
    ],
    'sql' => [//SQL记录器
        'handler' => [
            'class' => Monolog\Handler\RotatingFileHandler::class,
            'constructor' => [
                'filename' => $logger_path . '/sql/sql.log',
                'level' => Level::Debug
            ]
        ],
        'formatter' => [
            'class' => Monolog\Formatter\LineFormatter::class,
            'constructor' => [
                'format' => "%datetime% : %message%\n",
                'dateFormat' => 'y-m-d H:i:s',
                'allowInlineLineBreaks' => true
            ]
        ]
    ],
    'http' => [//HTTP请求访问日志
        'handler' => [
            'class' => Monolog\Handler\RotatingFileHandler::class,
            'constructor' => [
                'filename' => $logger_path . '/http/http.log',
                'level' => Level::Debug
            ]
        ],
        'formatter' => [
            'class' => Monolog\Formatter\LineFormatter::class,
            'constructor' => [
                'format' => "%datetime% || %message%\n",
                'dateFormat' => 'y-m-d H:i:s',
                'allowInlineLineBreaks' => true
            ]
        ]
    ],
    'exceptions' => [//异常记录
        'handler' => [
            'class' => Monolog\Handler\RotatingFileHandler::class,
            'constructor' => [
                'filename' => $logger_path . '/exceptions/exceptions.log',
                'level' => Level::Debug
            ]
        ],
        'formatter' => [
            'class' => Monolog\Formatter\LineFormatter::class,
            'constructor' => [
                'format' => $format,
                'dateFormat' => $dateFormat,
                'allowInlineLineBreaks' => true
            ]
        ]
    ],
    'serve' => [//服务日志记录
        'handler' => [
            'class' => Monolog\Handler\RotatingFileHandler::class,
            'constructor' => [
                'filename' => $logger_path . '/serve/serve.log',
                'level' => Level::Debug
            ]
        ],
        'formatter' => [
            'class' => Monolog\Formatter\LineFormatter::class,
            'constructor' => [
                'format' => $format,
                'dateFormat' => $dateFormat,
                'allowInlineLineBreaks' => true
            ]
        ]
    ],
    'crontab' => [//定时任务记录
        'handler' => [
            'class' => Monolog\Handler\RotatingFileHandler::class,
            'constructor' => [
                'filename' => $logger_path . '/crontab/crontab.log',
                'level' => Level::Debug
            ]
        ],
        'formatter' => [
            'class' => Monolog\Formatter\LineFormatter::class,
            'constructor' => [
                'format' => $format,
                'dateFormat' => $dateFormat,
                'allowInlineLineBreaks' => true
            ]
        ]
    ]
];
